<%--
  Created by IntelliJ IDEA.
  User: zhuhongyu
  Date: 2022/6/19
  Time: 22:27
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>绵阳城市学院宿舍管理系统</title>
    <link rel="icon" href="images/3.icon">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="layui/css/layui.css" tppabs="http://res.layui.com/layui/dist/css/layui.css"  media="all">

    <style>
        body {
            height: 100%;
            background: url('images/1.jpg') no-repeat;
            background-position-y: -120px;
        }
        table{
            opacity: 0.8;
            color: black;
        }
        table td{
            color: black;
        }
    </style>
</head>
<body>
<table class="layui-hide" id="test" lay-filter="test"></table>
<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>
<script src="./layui/layui.js" charset="utf-8"></script>

<script>
    layui.use('table', function(){
        var table = layui.table;
        table.render({
            elem: '#test'
            ,url:'Servlet.absenceStudentServlet'
            ,title: '用户数据表'
            ,cols: [[
                {type: 'checkbox',title:'全选',fixed: 'left'}
                ,{field: 'id', title: '学号', width:120}
                ,{field: 'name', title: '姓名', width:120}
                ,{field: 'sex', title: '性别', width:100}
                ,{field: 'spno', title: '专业', width:220}
                ,{field: 'classn', title: '班级', width: 100}
                ,{field: 'building', title: '宿舍楼', width: 120}
                ,{field: 'buildingnub', title: '寝室号', width: 120}
                ,{field: 'fudao', title: '辅导员', width: 120}
                ,{field: 'state', title: '状态', width: 110,}
                ,{title:'操作', toolbar: '#barDemo', width:140}
            ]]
        });

        table.on('tool(test)', function(obj){
            var data = obj.data;
            //console.log(obj)
            if(obj.event === 'del'){
                layer.confirm('真的删除行么', function(index){
                    obj.del();
                    layer.close(index);
                });
            } else if(obj.event === 'edit'){
                layer.prompt({
                    formType: 2
                    ,value: data.state
                }, function(value, index){
                    obj.update({
                        state: value
                    });
                    layer.close(index);
                });
            }
        });
    });
</script>
</body>
</html>